//
//  CellOfShopForPet.m
//  PetAPP
//
//  Created by apple on 16/2/18.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "CellOfShopForPet.h"
#import "ModelOfShopForPet.h"
#import <YYWebImage.h>
#import <DKNightVersion.h>

@interface CellOfShopForPet ()

@property (nonatomic, retain) UIImageView *imageViewOfPic;

@property (nonatomic, retain) UILabel *labelOfName;

@end

@implementation CellOfShopForPet

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createSubViewsWithFrame:(CGRect){.size = frame.size}];
    }
    return self;

}

- (void)createSubViewsWithFrame:(CGRect)frame {

    self.imageViewOfPic = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageViewOfPic];
    [_imageViewOfPic release];
    
    
    self.labelOfName = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfName];
    [_labelOfName release];


}

- (void)handleDataWithModel:(ModelOfShopForPet *)model {

//    self.imageViewOfPic.yy_imageURL = [NSURL URLWithString:model.img_url];
    [self.imageViewOfPic yy_setImageWithURL:[NSURL URLWithString:model.img_url] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];

    
    self.labelOfName.text = model.cat_name;
    self.labelOfName.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);

}


/** collectionCell 的子控件的布局通常在此方法中设置 */
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    
    self.imageViewOfPic.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 20);
    
    self.labelOfName.frame = CGRectMake(0, self.contentView.frame.size.height - 20, self.contentView.frame.size.width, 20 );
    self.labelOfName.textAlignment = NSTextAlignmentCenter;
    
}



@end
